const Koa = require('koa');
const koaBody = require('koa-body')
const app = new Koa()

const main = ctx => {
  const body = ctx.request.body
  console.log(body);
  if (!body.name) {
    ctx.throw(400)
  }
  ctx.response.body = { name: body.name}
}
app.use(koaBody())
app.use(main)

app.listen(3000, () => {
  console.log('服务器启动ing');
})